name: Github Actions

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK 21
        uses: actions/setup-java@v4
        with:
          java-version: '21'
          distribution: 'temurin'
          
      - name: Build with Gradle
        uses: gradle/gradle-build-action@v3
        with:
          gradle-version: 8.5
          arguments: build
          build-root-directory: app
        
      - name: Publish code coverage
        if: ${{ github.event_name == 'push' }}
        uses: paambaati/codeclimate-action@v5.0.0
        env:
          CC_TEST_REPORTER_ID: ${{secrets.CC_TEST_REPORTER_ID}}
          JACOCO_SOURCE_PATH: app/src/main/java
        with:
          debug: true
          coverageCommand: make -C app report
          coverageLocations: ${{github.workspace}}/app/build/reports/jacoco/test/jacocoTestReport.xml:jacoco
